'\" te
.\"  Copyright 1989 AT&T Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH BUSSTAT 8 "Nov 1, 1999"
.SH NAME
busstat \- report bus-related performance statistics
.SH SYNOPSIS
.LP
.nf
\fBbusstat\fR \fB-e\fR \fIdevice-inst\fR | \fB-h\fR | \fB-l\fR
.fi

.LP
.nf
\fBbusstat\fR [\fB-a\fR] [\fB-n\fR]
     [\fB-w \fR \fIdevice-inst\fR [,pic0=\fIevent\fR,pic\fIn\fR=\fIevent\fR ]]...
     [\fB-r\fR \fIdevice-inst\fR]... [\fIinterval \fR [\fIcount\fR]]
.fi

.SH DESCRIPTION
.sp
.LP
\fBbusstat\fR provides access to the bus-related performance counters in the
system. These performance counters allow for the measurement of statistics like
hardware clock cycles, bus statistics including \fBDMA\fR and cache coherency
transactions on a multiprocessor system. Each bus device that supports these
counters can be programmed to count a number of events from a specified list.
Each device supports one or more Performance Instrumentation Counters
(\fBPIC\fR) that are capable of counting events independently of each other.
.sp
.LP
Separate events can be selected for each \fBPIC\fR on each instance of these
devices. \fBbusstat\fR summarizes the counts over the last interval seconds,
repeating forever. If a count is given, the statistics are repeated count
times.
.sp
.LP
 Only root users can program these counters. Non-root users have the option of
reading the counters that have been programmed by a root user.
.sp
.LP
The default value for the \fIinterval\fR argument is 1 second, and the default
\fIcount\fR is unlimited.
.sp
.LP
The devices that export these counters are highly platform-dependent and the
data may be difficult to interpret without an in-depth understanding of the
operation of the components that are being measured and of the system they
reside in.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.sp .6
.RS 4n
Display absolute counter values. The default is \fBdelta\fR values.
.RE

.sp
.ne 2
.na
\fB\fB-e\fR \fIdevice-inst\fR\fR
.ad
.sp .6
.RS 4n
Display the list of events that the specified device supports for each pic.
.sp
Specify \fIdevice-inst\fR as device (\fBname\fR) followed by an optional
instance number. If an instance number is specified, the events for that
instance are displayed. If no instance number is specified, the events for the
first instance of the specified device are displayed.
.RE

.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.sp .6
.RS 4n
Print a usage message.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.sp .6
.RS 4n
List the devices in the system which support performance counters.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.sp .6
.RS 4n
Do not display a title in the output. The default is to display titles.
.RE

.sp
.ne 2
.na
\fB\fB-r\fR \fIdevice-inst\fR\fR
.ad
.sp .6
.RS 4n
Read and display all \fBpic\fR values for the specified device
.sp
Specify \fIdevice-inst\fR as \fIdevice\fR (\fBname\fR) followed by \fIinstance
number\fR, if specifying an instance number of a device whose counters are to
be read and displayed. If all instances of this device are to be read, use
\fIdevice\fR (\fBname\fR) without an instance number. All \fBpic\fR values will
be sampled when using the \fB-r\fR option.
.RE

.sp
.ne 2
.na
\fB\fB-w\fR \fIdevice-inst\fR [,pic0=\fIevent\fR] [,pic\fIn\fR=\fIevent\fR] \fR
.ad
.sp .6
.RS 4n
Program (write) the specified devices to count the specified events. Write
access to the counters is restricted to root users only. Non-root users can use
\fB-r\fR option.
.sp
Specify \fIdevice-inst\fR as \fIdevice\fR (\fBname\fR) followed by an optional
\fIinstance number\fR. If specifying an instance number of a device to program
these events on. If all instances of this device are to be programmed the same,
then use \fIdevice\fR without an instance number. Specify an event to be
counted for a specified \fBpic\fR by providing a comma separated list of
\fBpic\fIn\fR=\fR\fIevent\fR values.
.sp
The \fB-e\fR option displays all valid event names for each device. Any devices
that are programmed will be sampled every interval seconds and repeated count
times. It is recommended that the interval specified is small enough to ensure
that counter wraparound will be detected. The rate at which counters
wraparound varies from device to device. If a user is programming events using
the \fB-w\fR option and \fBbusstat\fR detects that another user has changed the
events that are being counted, the tool will terminate as the programmed
devices are now being controlled by another user. Only one user can be
programming a device instance at any one time. Extra devices can be sampled
using the \fB-r\fR option. Using multiple instances of the \fB-w\fR option on
the same command line, with the same \fIdevice-inst\fR specifying a different
list of events for the \fBpic\fRs will give the effect of multiplexing for that
device. \fBbusstat\fR will switch between the list of events for that device
every interval seconds. Event can be a string representing the event name, or
even a number representing the bit pattern to be programmed into the
Performance Control Register (\fBPCR\fR).  This assumes explicit knowledge of
the meaning of the  control register bits for a device.  The number can be
specified in hexadecimal, decimal, or octal, using the usual conventions of
\fBstrtol\fR(3C).
.RE

.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB0\fR
.ad
.RS 5n
Successful completion.
.RE

.sp
.ne 2
.na
\fB1\fR
.ad
.RS 5n
An error occurred.
.RE

.sp
.ne 2
.na
\fB2\fR
.ad
.RS 5n
Another user is writing to the same devices.
.RE

.SH EXAMPLES
.SS "SPARC Only"
.LP
\fBExample 1 \fRProgramming and monitoring the Address Controller counters
.sp
.LP
In this example, \fBac0\fR refers to the Address Controller instance 0. The
counters are programmed to count Memory Bank stalls on an Ultra Enterprise
system at 10 second intervals with the values displayed in absolute form
instead of deltas.

.sp
.in +2
.nf
# busstat -a -w ac0,pic0=mem_bank0_stall,pic1=mem_bank1_stall 10
time  dev   event0            pic0   event1             pic1
10    ac0   mem_bank0_stall   1234   mem_bank1_stall    5678
20    ac0   mem_bank0_stall   5678   mem_bank1_stall   12345
30    ac0   mem_bank0_stall  12345   mem_bank1_stall   56789
\&...
.fi
.in -2
.sp

.sp
.LP
For a complete list of the supported events for a device, use the \fB-e\fR
option.

.LP
\fBExample 2 \fRProgramming and monitoring the counters on all instances of the
Address Controller
.sp
.LP
In this example, \fBac\fR refers to all \fBac\fR instances. This example
programs all instances of the Address Controller counters to \fBcount_clock\fR
cycles and \fBmem_bank0_rds\fR at 2 second intervals, 100 times, displaying the
values as deltas.

.sp
.in +2
.nf
# busstat -w ac,pic0=clock_cycles,pic1=mem_bank0_rds 2 100
time  dev     event0          pic0            event1          pic1
2     ac0     clock_cycles    167242902       mem_bank0_rds   3144
2     ac1     clock_cycles    167254476       mem_bank0_rds   1392
4     ac0     clock_cycles    168025190       mem_bank0_rds   40302
4     ac1     clock_cycles    168024056       mem_bank0_rds   40580
\&...
.fi
.in -2
.sp

.LP
\fBExample 3 \fRMonitoring the events being counted
.sp
.LP
This example monitors the events that are being counted on the  sbus1 device,
100 times at 1 second intervals. It suggests that a root user has changed the
events that \fBsbus1\fR was counting to be \fBdvma_tlb_misses\fR and interrupts
instead of \fBpio_cycles\fR.

.sp
.in +2
.nf
% busstat -r sbus0 1 100

time    dev     event0               pic0       event1          pic1
1       sbus1   pio_cycles           2321       pio_cycles      2321
2       sbus1   pio_cycles           48         pio_cycles      48
3       sbus1   pio_cycles           49         pio_cycles      49
4       sbus1   pio_cycles           2281       pio_cycles      2281
5       sbus1   dvma_tlb_misses      0          interrupts      0
6       sbus1   dvma_tlb_misses      6          interrupts      2
7       sbus1   dvma_tlb_misses      8          interrupts      11
\&...
.fi
.in -2
.sp

.LP
\fBExample 4 \fREvent Multiplexing
.sp
.LP
This example programs \fBac0\fR to alternate between counting (clock cycles,
\fBmem_bank0_rds\fR) and (\fBaddr_pkts\fR, \fBdata_pkts\fR) at 2 second
intervals while also monitoring what \fBac1\fR is counting :

.sp
.LP
It shows the expected output of the above \fBbusstat\fR command. Another root
user on the machine has changed the events that this user had programmed and
\fBbusstat\fR has detected this and terminates the command with a message.

.sp
.in +2
.nf
# busstat -w ac0,pic0=clock_cycles,pic1=mem_bank0_rds \e
           -w ac0,pic0=addr_pkts,pic1=data_pkts \e
           -r ac1 2

time    dev     event0          pic0            event1          pic1
2       ac0     addr_pkts       12866           data_pkts       17015
2       ac1     rio_pkts        385             rio_pkts        385
4       ac0     clock_cycles    168018914       mem_bank0_rds   2865
4       ac1     rio_pkts        506             rio_pkts        506
6       ac0     addr_pkts       144236          data_pkts       149223
6       ac1     rio_pkts        522             rio_pkts        522
8       ac0     clock_cycles    168021245       mem_bank0_rds   2564
8       ac1     rio_pkts        387             rio_pkts        387
10      ac0     addr_pkts       144292          data_pkts       159645
10      ac1     rio_pkts        506             rio_pkts        506
12      ac0     clock_cycles    168020364       mem_bank0_rds   2665
12      ac1     rio_pkts        522             rio_pkts        522
busstat: events changed (possibly by another busstat).
#
.fi
.in -2
.sp

.SH SEE ALSO
.sp
.LP
.BR strtol (3C),
.BR attributes (7),
.BR iostat (8),
.BR mpstat (8),
.BR vmstat (8)
